package 
{
	import com.demonsters.debugger.MonsterDebugger;
	import com.google.analytics.AnalyticsTracker;
	import com.google.analytics.GATracker;
	import flash.display.MovieClip;
	import flash.external.ExternalInterface;
	import flash.text.TextField;
	
	import data.Feed;
	import display.DisplayControl;
	import flash.display.Sprite;
	import flash.display.StageDisplayState;
	import flash.display.StageScaleMode;
	import flash.display.StageAlign;
	import flash.events.Event;
	
	import controller.Controller;
	import model.Player;
	
	/**
	 * ...
	 * @author Henrik Riise Hansen
	 */
	
	public class Shell extends MovieClip 
	{
		// google analytics
		
		private var tracker:AnalyticsTracker;
		
		// player
		
		private var player:Player;
		
		// controller
		
		private var control:Controller
		
		// view
		
		private var videoControl:DisplayControl;
		
		public function Shell():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			 // Start the MonsterDebugger
            MonsterDebugger.initialize(this);
           
			
			this.stage.scaleMode = StageScaleMode.NO_SCALE;
			this.stage.align = StageAlign.TOP_LEFT;
		    
			build();
		}
		
		// build stage
		
		private function build():void
		{
			control = new Controller(this);
			
			//tracker = new GATracker( this, "UA-26372417-1", "AS3", false);
			
			videoControl = new DisplayControl(this,control);
			player = new Player(this, control);
			
			control.start(videoControl, player);
			
			addChild(player);
			addChild(videoControl);
		}
	}
}